Skip to content

Fix PreviousFork never selecting a fork at epoch 0 - #90

Open
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/previous-fork-epoch-zero
Open

Fix PreviousFork never selecting a fork at epoch 0#90
damilolaedwards wants to merge 1 commit into
ethpandaops:masterfrom
damilolaedwards:fix/previous-fork-epoch-zero

Conversation

@damilolaedwards

Copy link
Copy Markdown

Summary

The search seeded its running maximum at epoch 0 and only replaced it on a strict greater than, so a fork activating at epoch 0 could never win. Every real chain has its genesis fork at epoch 0, so PreviousFork returned "no previous fork" on any mainnet-shaped spec.

Fix changes the comparison to greater than or equal, matching how CurrentFork already does this same search.

Test plan

  • Added mainnet-shaped test cases to TestForkEpochsPreviousFork in pkg/beacon/state/fork_epoch_test.go: genesis fork at epoch 0, and a three-fork chain confirming the most recent previous fork is still picked correctly
  • Confirmed the new cases fail against the old strict comparison and pass against the fix
  • go build ./..., go vet ./..., go test -race ./... all green

The search seeded its running maximum at epoch 0 and only replaced
it on a strict greater than, so a fork activating at epoch 0 could
never win. Every real chain has its genesis fork at epoch 0, so
PreviousFork returned "no previous fork" on any mainnet-shaped spec.
Changed the comparison to greater than or equal, matching how
CurrentFork already does this same search.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant